/*
echo client.
**/

#include "str_cli.h"
#include <define.h>
#include <error.h>
#include <wrapfunc.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>


int
main(int argc, char **argv) {
	if (argc != 2)
		error_quit("usage: %s ip", argv[0]);
	const char *ip = argv[1];

	int fd = Socket(AF_INET, SOCK_STREAM, 0);
	
	struct sockaddr_in server_addr;
	memset(&server_addr, 0, sizeof(server_addr));
	server_addr.sin_family = AF_INET;
	server_addr.sin_port = htons(SERV_PORT);
	Inet_pton(server_addr.sin_family, ip, &server_addr.sin_addr);

	Connect(fd, (struct sockaddr*)&server_addr, sizeof(server_addr));
	str_cli(stdin, fd);
	Close(fd);
	return 0;
}
